package com.xsp.service.impl;

import com.xsp.dao.BookInfoDao;
import com.xsp.entity.BookInfo;
import com.xsp.service.BookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xsp
 * @date 2024/3/9
 * @desc
 */
@Service
public class BookServiceImpl implements BookService {
    @Resource
    private BookInfoDao bookInfoDao;

    @Override
    public void add(BookInfo bookInfo) {
        bookInfoDao.insert(bookInfo);
    }

    @Override
    public List<BookInfo> list() {
        return bookInfoDao.list();
    }

    @Override
    public List<BookInfo> find(String name) {
        return bookInfoDao.selectByName(name);
    }

    @Override
    public BookInfo find(Integer id) {
        return bookInfoDao.selectByPrimaryKey(id);

    }

    @Override
    public boolean remove(Integer id) {
        return bookInfoDao.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public boolean modify(BookInfo bookInfo) {
        return bookInfoDao.insert(bookInfo) > 0;
    }
}
